package com.ley.yikang.service.serviceimpl;

import com.ley.yikang.entity.CheckTask;
import com.ley.yikang.mapper.CheckTaskMapper;
import com.ley.yikang.service.CheckTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CheckTaskServiceImpl implements CheckTaskService {
    private final CheckTaskMapper checkTaskMapper;

    @Autowired
    public CheckTaskServiceImpl(CheckTaskMapper checkTaskMapper) {
        this.checkTaskMapper = checkTaskMapper;
    }

    @Override
    public List<CheckTask> getAllCheckTask() {
        return checkTaskMapper.getAllCheckTask();
    }

    @Override
    public List<CheckTask> getDoctorCheckTask(int doctorId, Date date, int id) {
        // 使用Map封装可选参数
        Map<String, Object> params = new HashMap<>();
        params.put("doctorId", doctorId);
        if (date != null) {
            params.put("date", date);
        }
        if (id != 0) {
            params.put("id", id);
        }
        return checkTaskMapper.getDoctorCheckTask(params);
    }

    @Override
    public CheckTask getCheckTaskById(int id) {
        return checkTaskMapper.getCheckTaskById(id);
    }

    @Override
    public void delCheckTask(int id) {
        checkTaskMapper.delCheckTask(id);
    }

    @Override
    public void updateDoctorCheckTask(CheckTask checkTask) {
        checkTaskMapper.updateDoctorCheckTask(checkTask);
    }

    @Override
    public void addCheckTask(CheckTask checkTask) {
        checkTaskMapper.addCheckTask(checkTask);
    }

    @Override
    public List<CheckTask> getElderCheckTask(int elderId, Date date) {
        Map<String, Object> params = new HashMap<>();
        params.put("elderId", elderId);
        if (date != null) {
            params.put("date", date);
        }
        return checkTaskMapper.getElderCheckTask(params);
    }

    @Override
    public void delElderCheckTask(int id) {
        checkTaskMapper.delElderCheckTask(id);
    }

    @Override
    public void updateElderCheckTask(CheckTask checkTask) {
        checkTaskMapper.updateElderCheckTask(checkTask);
    }

    @Override
    public void delDoctorCheckTask(int id) {
        checkTaskMapper.delDoctorCheckTask(id);
    }
}
